package com.ktodo.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Eric on 2018/8/10.
 * Email:starfall.lsq@gmail.com
 */
public class MView extends View {

    private Paint mPaint = new Paint();

    public MView(Context context) {
        super(context);
    }

    public MView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public MView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mPaint.setAntiAlias(true);
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(3);
        mPaint.setStyle(Paint.Style.STROKE);
//        canvas.drawCircle(300, 300, 200, mPaint);
//        mPaint.setStyle(Paint.Style.FILL);
//        canvas.drawRoundRect(600, 100, 1000, 300, 50, 50, mPaint);
//        canvas.drawColor(Color.parseColor("#77770000"));
//        mPaint.setStyle(Paint.Style.STROKE);
//        Rect rect = new Rect(100, 600, 500, 800);
//        canvas.drawRect(rect, mPaint);
//        canvas.drawRect(600, 600, 1100, 800, mPaint);
//        mPaint.setStrokeWidth(40);
//        mPaint.setColor(Color.BLACK);
//        mPaint.setStrokeCap(Paint.Cap.ROUND);
//        canvas.drawPoint(300, 1000, mPaint);
//        mPaint.setStrokeCap(Paint.Cap.BUTT);
//        canvas.drawPoint(400, 1000, mPaint);
//        mPaint.setStrokeCap(Paint.Cap.SQUARE);
//        canvas.drawPoint(500, 1000, mPaint);
//        float[] points = {300, 1200, 400, 1200, 500, 1200, 600, 1200};
//        float[] points2 = {300, 1300, 400, 1300, 500, 1300, 600, 1300, 700, 1300, 800, 1300};
//        mPaint.setColor(Color.BLUE);
//        mPaint.setStrokeCap(Paint.Cap.ROUND);
//        canvas.drawPoints(points, mPaint);
//        mPaint.setColor(Color.RED);
//        mPaint.setStrokeCap(Paint.Cap.SQUARE);
//        canvas.drawPoints(points2, 2, 4, mPaint);
//        mPaint.setStyle(Paint.Style.FILL);
//        canvas.drawOval(100, 1400, 500, 1600, mPaint);
//        RectF rectF = new RectF(600, 1400, 1000, 1600);
//        mPaint.setStyle(Paint.Style.STROKE);
//        mPaint.setStrokeWidth(10);
//        canvas.drawOval(rectF, mPaint);
//        canvas.drawLine(100, 1700, 400, 1700, mPaint);
//        canvas.drawLine(100, 1800, 400, 2000, mPaint);
//        RectF rectF = new RectF(300, 300, 800, 600);
//        Rect rect = new Rect(300, 300, 800, 600);
//        canvas.drawRect(rect, mPaint);
//        mPaint.setColor(Color.BLACK);
//        canvas.drawOval(rectF, mPaint);
//        mPaint.setColor(Color.BLUE);
//        canvas.drawArc(rectF, -180, 90, true, mPaint);

//        Path path = new Path();
//        mPaint.setStyle(Paint.Style.FILL);
//        path.addCircle(300, 300, 200, Path.Direction.CCW);
//        path.addCircle(500, 300, 200, Path.Direction.CW);
//        canvas.drawPath(path, mPaint);
        mPaint.setStyle(Paint.Style.STROKE);
        Path path1 = new Path();
//        path1.lineTo(300, 300);
//        path1.rLineTo(300, 0);
        path1.quadTo(300, 300, 600, 100);
        canvas.drawPath(path1, mPaint);


    }
}
